package com.xxc.example.controller;

import com.xxc.example.service.LogSampleService;
import com.xxc.logger.annotation.NoLog;
import com.xxc.response.anotation.OriginResponse;
import com.xxc.response.anotation.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试通用返回的controller
 * 由于添加了Logger的依赖，请求的方法会自动打印参数和响应日志 {@link com.xxc.logger.handler.LoggerAspect}
 * 只需给Controller以@RestController以及@ResponseResult注解就可以将响应包裹在{@link ResponseResult}中设置的Result类中
 * @author xxc、
 */
@Controller
@ResponseResult
@RequestMapping("/norest")
// 不打印该类的日志
@NoLog
public class NoRestController {

    @Autowired
    LogSampleService logSampleService;

    /**
     * 如果所在的类不是被{@link RestController} 注解而是Controller，则方法需要{@link ResponseBody}注解
     * @return
     */
    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return logSampleService.sayHello("xxc");
    }

}
